/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2018-2023.
 * Description: init rtos task_struct extend support add new member by rtos
 * Author: nixiaoming
 * Create: 2018-2-13
 */

#ifdef CONFIG_RTOS_MM_EXTEND
#include <linux/rtos_mm_types.h>

#include <linux/rtos/coredump_on_exit.h>

/* init new member for rtos mm_struct here*/
struct rtos_mm_struct rtos_init_mm = {
#ifdef CONFIG_RTOS_IDUMP
	.idump.dump_filter_type = 1,
	.idump.stacksize = 0,
#if defined(CONFIG_RTOS_IDUMP_FORCE) || defined(CONFIG_RTOS_IDUMP_TRIGGER)
	.idump.core_state = NULL,
	.idump.timeout_msec = 1000,
#endif
#ifdef CONFIG_RTOS_IDUMP_FORCE
	.idump.sig_force = {0},
#endif
#endif
#ifdef CONFIG_RTOS_COREDUMP_ON_EXIT
	.dump_on_exit = false,
#endif
};

/* only called by mm_init, after check mm != NULL */
void rtos_mm_struct_init(struct mm_struct *mm)
{
	struct rtos_mm_struct *rtos_mm = mm_to_rtos_mm(mm);

	memset((char *)rtos_mm, 0, sizeof(*rtos_mm));
#ifdef CONFIG_RTOS_IDUMP
	init_idump_mm_extend(&rtos_mm->idump);
#endif
#ifdef CONFIG_RTOS_COREDUMP_ON_EXIT
	init_dump_on_exit(rtos_mm);
#endif
}
#endif
